<template>
	<div class="dianji">

		<div class="dianji_content">
			<div class="list">
				<span class="_span">{{title}}</span>
			</div>
			<div class="text">
				<p class="title">{{title}}</p>
				<p class="content">{{desc}}</p>
			</div>
		</div>
		<div style="margin-top: 50px;">
			<div class="zhangjie" v-for="(item,index) in shiciList">
				<div class="text">
					<p class="title">{{item.name}}纪</p>
					<div class="item">
						<p @click="jump(items.name1,items.name)" v-for="(items,indexs) in item.children">{{items.name}}</p>
					</div>
				</div>
			</div>
		</div>

	</div>
</template>

<script>
	export default {

		data() {
			return {
				title: "",
				desc: "",
				top: false,
				pageNum: 0,
				pageSize: 30,
				moreText: '加载中...',
				shiciList: [],
				titles: [],
			}
		},

		onLoad(options) {
			this.title = options.name;
			this.desc = options.desc;
			this.list()
		},
		onShareAppMessage(res) {
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			})
			return {
				title: this.title,
				imageUrl: 'https://www.leedong.top/img/11556.png',
				path: '/pageA/zuozhuan/zuozhuan?name=' + this.title + '&desc=' + this.desc
			}
		
		},
		//2.分享到朋友圈
		onShareTimeline() {
		
			return {
				title: this.title,
				imageUrl: 'https://www.leedong.top/img/11556.png',
				path: '/pageA/zuozhuan/zuozhuan?name=' + this.title + '&desc=' + this.desc
		
			}
		},
		methods: {
			jump(name,name1) {

				uni.navigateTo({
					url: '/pagesA/zuozhuan/zuozhuandetails/zuozhuandetails?content=' + name+'&name1='+name1
				})
			},
		
			async list() {
				let title = [{
					name: '隐公',
					children: []
				}, {
					name: '庄公',
					children: []
				}, {
					name: '僖公',
					children: []
				}, {
					name: '桓公',
					children: []
				}, {
					name: '闵公',
					children: []
				}, {
					name: '文公',
					children: []
				},
				{
					name: '宣公',
					children: []
				}, {
					name: '成公',
					children: []
				}, {
					name: '襄公',
					children: []
				}, {
					name: '昭公',
					children: []
				}, {
					name: '定公',
					children: []
				}, {
					name: '哀公',
					children: []
				},
				];
				const data = await this.$api.zuozhuan({
					content: ''
				});
				uni.showLoading({
					title:'加载中...'
				})
				for (let i = 0; i < title.length; i++) {
					for (let j = 0; j < data.rows.length; j++) {
						let str=data.rows[j].title.split(" · ")[1];
						if (str== title[i].name) {
							title[i].children.push({name:data.rows[j].title.split(" · ")[2],name1:data.rows[j].id})
						}
					}
				}
				
				this.shiciList = title;
				uni.hideLoading()
			},


		}
	}
</script>

<style lang="scss">
	.dianji {

		.dianji_content {

			margin-top: 20px;
			border-bottom: 1px solid #ffdcdc;
			margin-bottom: 10px;

			.list {
				width: 22%;
				height: 130px;
				float: left;
				background-image: url('https://www.leedong.top/img/dianji1.png');
				background-size: 100% 100%;

				._span {
					writing-mode: tb-rl;
					padding-left: 12px;
					padding-top: 21px;
					font-size: 12px;
					font-weight: 800;
				}
			}

			.text {

				padding-left: 20px;

				.title {
					color: $color;
					font-size: 30rpx;

				}

				.content {
					font-size: 25rpx;
					padding-top: 10rpx;
					line-height: 18px;
					text-indent: 4ch;
					color: #616161;
					padding-bottom: 20rpx;
				}

			}
		}

		.zhangjie {


			.title {
				font-size: 35rpx;
				font-weight: 800;
				color: #7d8468;
				padding: 30px;


			}

			.item {
				display: flex;
				
				flex-wrap: wrap;

				p {
					width: 25%;
					font-size: 30rpx;
					padding: 15px;
				}
			}
		}
	}
</style>